<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-3.2.1.min.js"></script>
    <script src="jquery.query.js"></script>
    <script>
        $(function () {
            var str = $.query().get("info");
            if(str != null && str == "nologin"){
                $("#errorSpan").html("请先登录");
            }
        });


        function login() {
            $.post("/user/login",$("#f1").serialize(),function (info) {
                if(info == "no"){
                    $("#errorSpan").html("登录失败");
                }else {
                    var obj = JSON.parse(info);
                    if("顾客" == obj.grade){
                        location.href="/html/index.html"
                    }else if ("管理员" == obj.grade){
                        location.href="/html/manager/managerIndex.html"
                    }else if ("送货员" == obj.grade) {
                        location.href="/html/sender/senderIndex.html"
                    }
                }
            })
        }
    </script>
</head>
<body>
    <span id="errorSpan" style="color: red"></span>
    <form id="f1">
        用户名：<input type="text" name="userName"><br>
        密  码：<input type="text" name="psw"><br>
        <input type="button" value="登录" onclick="login()">
    </form>
</body>
</html>